package project

import (
	"github.com/gin-gonic/gin"
	"ylm.sl/global"
	"ylm.sl/internal/api/controller"
	"ylm.sl/internal/repository/dao"
	"ylm.sl/internal/service"
)

type ShortLinkRouter struct {
	service service.IShortLinkService
}

func (sr *ShortLinkRouter) InitApiRouter(router *gin.RouterGroup) {
	sr.service = service.NewShortLinkService(dao.NewShortLinkDao(global.DB), (*global.Bloom)["shortUriCreateCachePenetrationBloomFilter"])
	shortLinkController := controller.NewShortLinkController(sr.service)

	privateRouter := router
	{
		privateRouter.POST("create", shortLinkController.CreateShortLink)
		privateRouter.POST("create/by-lock", shortLinkController.CreateShortLinkByLock)
		privateRouter.POST("create/batch", shortLinkController.BatchCreateShortLink)
		privateRouter.POST("update", shortLinkController.UpdateShortLink)

	}

}
